/**
 * game 初始化js
 */
import common from './global/common'
import BWU from './global/bw-util'
cc.Class({
    extends: cc.Component,

    properties: {
        btns: [cc.Button],
    },
    onLoad() {
        //全局log 
        window.log = function () {
            this.apply(window, arguments);
        }.bind(console.log);

        this.btns.forEach((btn, index) => {
            let node = btn.node;
            BWU.btnClickLimit(node, this);
            node.on('click', this.onClickBtn.bind(this, index));
        });
    },
    onClickBtn(i) {
        switch (i) {
            case 0:
                this.loadBoard();
                break;

            default:
                break;
        }

    },
    loadBoard() {
        BWU.toLoadPrefab(common.prefabName.board, this, (prefab) => {
            let node = cc.instantiate(prefab);
            node.getComponent('board').init('test');
            this.node.addChild(node);
        })
    },
    start() {

    },

    // update (dt) {},
});
